#include <bits/stdc++.h>
using namespace std;
const int N=1E3+10;
using ll =long long int;
int main()
{
    ll n,m,q;cin>>n>>m>>q;
    ll nums[N][N];
    auto sum=nums;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++) cin>>nums[i][j];
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+nums[i][j];
        }
    }
    while(q--)
    {
        ll x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        cout<<sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]<<endl;
    }
    return 0;
}
